package com.myblog.controller;

import com.myblog.annotation.Log;
import com.myblog.domain.GlobalResponse;
import com.myblog.domain.contants.GlobalConstants;
import com.myblog.domain.entity.Comment;
import com.myblog.services.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comment")
@Api(tags = "评论控制器")
public class CommentController {

    @Resource
    CommentService commentService;
    @GetMapping("/commentList")
    @Log(BusinessName = "获取评论列表")
    @ApiOperation(value = "获取评论列表",notes = "根据分页信息获取评论列表")
    public GlobalResponse getCommentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.getCommentList(GlobalConstants.IS_ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    @PostMapping()
    @Log(BusinessName = "发送评论")
    @ApiOperation(value = "发送评论")
    public GlobalResponse sendComment(@RequestBody Comment comment) {
        return commentService.sendComment(comment);
    }

    @GetMapping("/linkCommentList")
    @Log(BusinessName = "获取友链评论")
    @ApiOperation(value = "获取友链评论")
    public GlobalResponse getLinkCommentList(Integer pageNum,Integer pageSize){
        return commentService.getCommentList(GlobalConstants.IS_LINK_COMMENT,GlobalConstants.HAVE_NO_ARTICLEID,pageNum,pageSize);

    }

}
